package com.qf.fcy.youshare.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.qf.fcy.youshare.R;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Alex[FR]
 * Date: 2015/2/4
 * Email: alex_fcy@163.com
 */
public class EnterAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<Map<String, Object>> list;


    public EnterAdapter(Context context, List<Map<String, Object>> list) {
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        int gr = (parent.getHeight() - 10) / 2;
        View view = inflater.inflate(R.layout.item_main_eneter_point, null);
        view.setMinimumHeight(gr);
        LinearLayout layout = (LinearLayout) view.findViewById(R.id.item_layout);
        ImageView img = (ImageView) view.findViewById(R.id.item_enter_point_icon);
        TextView title = (TextView) view.findViewById(R.id.item_enter_point_title);

        Map<String, Object> map = list.get(position);
        layout.setBackgroundResource((Integer) map.get("itemBg"));
        img.setImageResource((Integer) map.get("itemIconId"));
        title.setText((String) map.get("itemTitle"));

        return view;
    }
}
